<?php

namespace app\admin\validate;

use think\Validate;

class District extends Validate
{

    /**
     * 验证规则
     */
    protected $rule = [
        'parent_id' => 'number',
        'citycode'  => 'require|max:255',
        'adcode'    => 'require|max:255',
        'name'      => 'require|max:255',
        'lng'       => 'number',
        'lat'       => 'number',
        'level'     => 'require|number',
    ];

    /**
     * 提示消息
     */
    protected $message = [];

    /**
     * 字段描述
     */
    protected $field = [];

    protected $scene = [
        'add'   =>  ['parent_id', 'name', 'citycode', 'adcode', 'lng', 'lat'],
        'edit'  =>  ['parent_id', 'name', 'citycode', 'adcode', 'lng', 'lat'],
        'import'  =>  ['province', 'city', 'district', 'street'],
    ];

    public function __construct(array $rules = [], $message = [], $field = [])
    {
        $this->field = [
            'name'          => __('Name'),
            'parent_id'     => __('Parent id'),
            'citycode'      => __('Citycode'),
            'adcode'        => __('Adcode'),
            'lng'           => __('Lng'), 
            'lat'           => __('Lat'),
            'level'         => __('Level'),
        ];
        parent::__construct($rules, $message, $field);
    }
}
